
#ifndef __NMALLOC_H__
#define __NMALLOC_H__

#ifdef _CHECK_LEAK

#define __MARK__ __FILE__,__LINE__

#define calloc(n, s)	ncalloc(__MARK__, (n), (s))
#define malloc(s)		nmalloc(__MARK__, (s))
#define realloc(p, s)	nrealloc(__MARK__, (p), (s))
#define strdup(s)		nstrdup(__MARK__, (s))
#define strndup(s, n)	nstrndup(__MARK__, (s), (n))
#ifdef _wcsdup
#undef _wcsdup
#endif
#define wcsdup(s)		n_wcsdup(__MARK__, (s))
#define _wcsdup(s)		n_wcsdup(__MARK__, (s))
#define free(p)			nfree(__MARK__, (p))

#define SHOW_LEAK_CHECK show_malloc_status()

#else
#define SHOW_LEAK_CHECK
#endif // _CHECK_LEAK

#ifndef WIN32
#include <sys/types.h>
#include <ncrypt_types.h>
#endif

void *ncalloc(char* file, int line, size_t nmemb, size_t size);
void *nmalloc(char* file, int line, size_t size);
void *nrealloc(char* file, int line, void *ptr, size_t size);
char *nstrdup(char* file, int line, const char *s);
LPWSTR n_wcsdup(char* file, int line, LPCWSTR s);
char *nstrndup(char* file, int line, const char *s, size_t n);
void nfree(char* file, int line, void *ptr);
void show_malloc_status();

#endif // __NMALLOC_H__
